package com.cn.ZhiKeDianShang.adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;

import com.cn.ZhiKeDianShang.R;
import com.cn.ZhiKeDianShang.base.RecycleAndListBaseAdapter.RecycleBaseAdapter.RecycleBaseViewHolder;
import com.cn.ZhiKeDianShang.base.RecycleAndListBaseAdapter.RecycleBaseAdapter.RecycleListBaseAdapter;
import com.cn.ZhiKeDianShang.model.response.RelateLiist;

import java.util.List;


public class RelateAdapter extends RecycleListBaseAdapter<RelateLiist.RelatedBean> {

    private Context mContext;
    private Animation mLikeAnim;
    private onItemClick onItemClick;

    public RelateAdapter(Context context, int layoutId, List<RelateLiist.RelatedBean> datas, onItemClick onItemClick) {
        super(context, layoutId, datas);
        this.mContext = context;
        mLikeAnim = AnimationUtils.loadAnimation(context, R.anim.anim_like);
        this.onItemClick = onItemClick;
    }


    @Override
    public void convert(RecycleBaseViewHolder helper, RelateLiist.RelatedBean relatedBean, int position) {
        helper.setText(R.id.tv_title, relatedBean.getNickname() + "");
        TextView tv_type = helper.getView(R.id.tv_type);
//关联状态  0申请中1待处理2已关联,当等于1的时候，有个处理操作按钮，请求操作关联接口
        switch (relatedBean.getStatus()) {
            case 0:
                tv_type.setText("申请中");
                tv_type.setTextColor(mContext.getResources().getColor(R.color.theme_color));
                tv_type.setBackground(null);
                break;
            case 1:
                tv_type.setText("处理");
                tv_type.setTextColor(mContext.getResources().getColor(R.color.white));
                tv_type.setBackground(mContext.getResources().getDrawable(R.drawable.button_shape_blue_5));
                tv_type.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        onItemClick.deal(position);
                    }
                });
                break;
            case 2:
                tv_type.setText("已关联");
                tv_type.setTextColor(mContext.getResources().getColor(R.color.text_color_black));
                tv_type.setBackground(null);
                break;
        }
////
        helper.getConvertView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onItemClick.onItemClick(position);
            }
        });
    }

    @Override
    public void convert(RecycleBaseViewHolder helper, RelateLiist.RelatedBean tiktokBean, List<Object> payloads, int position) {
        Log.d("Debug", "到达局部刷新这里-------------------->>>>payloads" + payloads);
    }


    public interface onItemClick {
        void onItemClick(int position);

        void deal(int position);

    }
}
